package com.zyh.map;

import com.zyh.map.domain.Student;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * @Author zyh
 * @Date 2024/8/2 11:37
 * @Description 自定义类型的排序
 */

public class TreeMapDemo2 {
    public static void main(String[] args) {
        TreeMap<Student,String > map=new TreeMap<>();
        map.put(new Student("zyh",20),"zyh");
        map.put(new Student("cxk",10),"cxk");
        map.put(new Student("gg",10),"gg");
        map.put(new Student("dz",27),"dz");
        map.put(new Student("wy",6),"wy");
        Set<Map.Entry<Student, String>> entries = map.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            System.out.println(entry.getKey()+"--"+ entry.getValue());
        }
    }
}
